// 云函数入口文件
const cloud = require('wx-server-sdk')
//安装依赖：npm install --save wx-server-sdk@latest
cloud.init()

// 云函数入口函数
exports.main = async (event, context) => {
  //实例化数据库连接
  const db = cloud.database()
  //接收结果
  var supplies_list = []

  await db.collection('supplies')
  .get()
  .then(res =>{
    supplies_list = res.data
  })
  var result = {}
  result.errCode = 0
  result.errMsg = 'ok'

  var data = {}
    data.supplies_list = supplies_list
    
    result.data = data
    return result
}